Repository navigation
fix(core): avoid stale length in native suffix reads - #9225
Merged
Merged
Conversation
Use the file length from the suffix open to enforce an exact size. If that response omits the file length, enforce the requested upper bound and let the underlying stream validate response completeness.
PsiACE
approved these changes
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Part of #9196. Follow-up to #9220.
Rationale for this change
A reused
Readercan reject valid suffix data after an overwrite if the current response omits the total file length. In the HTTP loopback test, a first range read observes a two-byte file. The same reader then sendsRange: bytes=-4and receives206 Partial Contentwith an unknown total. After growth to six bytes,Content-Range: bytes 2-5/*returnscdef, which #9220 rejects as too much data. After a shrink to one byte,Content-Range: bytes 0-0/*returnsz, which #9220 rejects as too little data. Both errors use the cached length of two. RFC 9110 §14.4What changes are included in this PR?
BufferStreamrequires exactlymin(n, file_length)bytes when the current suffix response supplies the file length. With no file length in that response, it caps the read atnand accepts a clean EOF below that bound. This uses the existing open reply without an extrastat.The loopback test also checks that the default reader surfaces a framing error when all requested bytes arrive but the final HTTP chunk marker is missing. The existing
RetryLayerbehavior treats a temporary stream error after the requested byte count as EOF.Are there any user-facing changes?
Applications can reuse a
Readerfor native suffix reads across size changes, andReader::metadata()continues to expose the first observed metadata. Chunked suffix reads,FuturesAsyncReadersuffix reads, and open-ended range planning remain part of #9196.Breaking changes
AI Usage Statement
pivia T3, modelmagpie/codex/gpt-6.2-astra, efforthigh. Traced the remaining suffix failure and scoped the follow-up.pivia T3, modelmagpie/codex/gpt-6.2-sol, effortmax. Implemented the core fix and reproduced the failure through the public HTTP reader against a local origin.pivia T3, modelmagpie/agy-cli/gemini-4-neon, efforthigh. Independently reviewed the signed change and drafted the PR description.